import request from '@/utils/request'

export function add(data) {
  return request({
    url: 'api/prePurchaseRequestDetail',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: 'api/prePurchaseRequestDetail/',
    method: 'delete',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: 'api/prePurchaseRequestDetail',
    method: 'put',
    data
  })
}

export function list(id) {
  return request({
    url: 'api/prePurchaseRequestDetail/list/' + id,
    method: 'get',
  })
}

export function query(params) {
  return request({
    url: 'api/prePurchaseRequestDetail',
    method: 'get',
    params
  })
}

export function download(ids) {
  // console.log(ids)
  var params = {
    'prePurchaseRequestId': ids
  }
  return request({
    url: 'api/prePurchaseRequestDetail/download',
    method: 'get',
    responseType: 'blob',
    params
  })
}

export function pass(ids, supplierName, purchaseAttribute) {
  let params = {
    'ids': ids,
    'supplierName': supplierName,
    'purchaseAttribute': purchaseAttribute
  }

  return request({
    url: 'api/prePurchaseRequestDetail/pass',
    method: 'post',
    data: params
  })
}

export default { add, edit, del, list, query, download, pass }
